package cn.baiyang.rocketmq.spring.support.ratelimit;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 限流器参数的缓存对象，包括参数值缓存和参数变化状态缓存。
 * <br>
 * 之所以用多个缓存对象，是为了避免缓存结构中键值的拼接处理，节约处理时间。
 *
 * @author hongzhu
 * @version V1.0
 * @since 2024-03-14 10:00
 */
public class RateLimiterParamsHolder {

    public static final String TOPIC_LIMIT_ENABLED = "${%s.enabled}";
    public static final String TOPICTAG_LIMIT_ENABLED = "${%s.%s.enabled}";
    public static final String TOPIC_LIMIT = "${%s.limit}";
    public static final String TOPICTAG_LIMIT = "${%s.%s.limit}";
    public static final long DEFAULT_QPS = 50;
    public static final long INITIAL_TOKENS = 1;

    /**
     * 参数值缓存数据
     */
    public static final ConcurrentHashMap<String, Long> PARAM_HOLDER = new ConcurrentHashMap<>();

    /**
     * 参数值的变化状态缓存数据，发生了改变则状态的值为True。
     */
    public static final ConcurrentHashMap<String, Boolean> CHANGED_HOLDER = new ConcurrentHashMap<>();

}
